# Global ARG
ARG PROJECT_DIRECTORY=/tmp/server

FROM maven:3.8-openjdk-17 as builder

ARG PROJECT_DIRECTORY
WORKDIR $PROJECT_DIRECTORY

COPY . .

FROM builder AS build

RUN mvn clean package -Dmaven.test.skip

FROM eclipse-temurin:17-jre-alpine

ARG PROJECT_DIRECTORY
WORKDIR $PROJECT_DIRECTORY

COPY --from=build $PROJECT_DIRECTORY/target/*.jar server.jar

EXPOSE 8080

ENTRYPOINT ["java", "-jar", "server.jar"]